//
//  BVIndexTool.m
//  XiangYu
//
//  Created by YYKJ on 2017/6/29.
//  Copyright © 2017年 YYKJ. All rights reserved.
//

#import "BVIndexTool.h"
#import "BVIndexModel.h"

#define CODE @"1"
@implementation BVIndexTool

-(void)fetchSystemRecommendedPage:(NSString *)page
                          Success:(void(^)(NSMutableArray *arr))success
                      codeFailure:(void(^)(NSString *str))codeFailure
                          failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/app/index/index.html",PATH];
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"uid"] = @"20170400";
    params[@"page"] = page;
    NSLog(@"----uid---%@",self.user.user_id);
    NSMutableArray *arr = [NSMutableArray array];
    [[BVHttpManager sharedNetManager]requstUrl:url method:Post parameters:params success:^(id responseObject) {
        BVLog(@"----服务器返回的----%@",responseObject[@"message"]);
        NSString *str= [NSString stringWithFormat:@"%@",responseObject[@"status"]];
        if (([str isEqualToString:CODE] && responseObject!=nil)) {
            for (NSMutableDictionary *dic in responseObject[@"list"]) {
                BVIndexModel *model = [BVIndexModel mj_objectWithKeyValues:dic];
                [arr addObject:model];
            }
            success(arr);
        }else{
            codeFailure(responseObject[@"message"]);
        }
    } failure:^(NSError *error) {
         failure(error);
    }];
    
}

@end
